package com.app.megaprosoft.modyimcarcare;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import com.megaprosoft.modyimcarcare.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class services_edit extends Activity {
	
	DecimalFormat df = new DecimalFormat("#,###,##0.00");	
	
	Button 		btn1,Sum,edit;
	TextView	TextSum,et1,et2,et0,et4,et5,et6,et7,et8,et9,et10,et11,et12,et13,et14,et15,et16,SumAmount;	
	CheckBox 	c1,c2,c0,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16;
	RadioButton rbA,rbB,rbC,rb5,rb6;
	double a = 0,b  = 0,a0  = 0,d = 0,e = 0,f = 0,g = 0,h = 0,ii = 0,jj = 0,k = 0,l = 0,m = 0,n = 0,o = 0,p = 0,q = 0,r = 0 ,subSum = 0,finalSum = 0,amount = 0;
	EditText	disc,prom,disBTH;
	connect con = new connect(); 
	ResultSet rs,rs0;
	ResultSet rs2,rs3,rs10;
	int timeSum = 0;
	String list1="",list2="",list0="",list4="",list5="",list6="",list7="",list8="",list9="",
			list10="",list11="",list12="",list13="",list14="",list15="",list16="",list17="",list18="";
	
	String price1="",price2="",price0="",price4="",price5="",price6="",price7="",price8="",price9="",
			price10="",price11="",price12="",price13="",price14="",price15="",price16="",price17="",price18="";
	
	int t1 = 0,t2 = 0,t0 = 0,t4 = 0,t5 = 0,t6 = 0,t7 = 0,t8 = 0,t9 = 0,t10 = 0,t11 = 0,t12 = 0,t13 = 0,t14 = 0,t15 = 0;
	
	String DisCt,sumDisc,sumDisBTH,sumDiscNull,sumDisBTHNull,VIPcode,id,addSer ;
	Spinner spnDis;
	
	ArrayList<String> Dis = new ArrayList<String>();
	
	    private int mYear;
	    private int mMonth;
	    private int mDay;
	    
	    String checkOrther1 = "";
	    EditText orther1,orther2,orther3;
	    
	ArrayList<String> price = new ArrayList<String>();
	
	String[] arr ;
	String[] arr2;
	String[] arr3;
	
	   String getCarIDEDT;	
	   String  ServiceIDEDT;	
	   String RegisterIDEDT;
	   String  TypeIDEDT;
	   String  CarGroupIDEDT;
	   String idDataService;
	   
	   AlertDialog.Builder dDialog0,dDialog1,dDialog2,dDialog3,dDialog4;
	   
	   String NameInput,company,DiscountNameEDT;
	
	   String timeHole,sumHole,listHole,priceHole;
	   
	   public static final int REQUEST_CODE = 1;  
	    public static boolean CHECH_ADD = true; 
	   
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		setContentView(R.layout.services_edit);
		
		NameInput = getIntent().getExtras().getString("name");
		company = getIntent().getExtras().getString("CompanyS");
		addSer = getIntent().getExtras().getString("addSer");
		
		
		
		c16 = ( CheckBox ) this.findViewById ( R.id.check16);	
		 
		 et16 = ( EditText ) this.findViewById ( R.id.result16);
		 et16.setEnabled(false);
		 
		 orther1 = ( EditText ) this.findViewById ( R.id.orther1);
		 orther1.setEnabled(false);
		
		 // ��Ǩ�Ѻ��ä�ԡ������ҧ�
	    	

			 c1 = ( CheckBox ) this.findViewById ( R.id.check1 );			
			 et1 = ( TextView ) this.findViewById ( R.id.result1 );
			 
			 c2 = ( CheckBox ) this.findViewById ( R.id.check2 );			
			 et2 = ( TextView ) this.findViewById ( R.id.result2 );
			 
		     c4 = ( CheckBox ) this.findViewById ( R.id.check4 );			
			 et4 = ( TextView ) this.findViewById ( R.id.result4 );
				
			 c0 = ( CheckBox ) this.findViewById ( R.id.check0 );			
			 et0 = ( TextView ) this.findViewById ( R.id.result0 );
				
			 c5 = ( CheckBox ) this.findViewById ( R.id.check5 );			
			 et5 = ( TextView ) this.findViewById ( R.id.result5 );
					
			 c6 = ( CheckBox ) this.findViewById ( R.id.check6 );			
			 et6 = ( TextView ) this.findViewById ( R.id.result6 );
			 
			 c7 = ( CheckBox ) this.findViewById ( R.id.check7 );			
			 et7 = ( TextView ) this.findViewById ( R.id.result7 );
					 
			 c8 = ( CheckBox ) this.findViewById ( R.id.check8 );			
			 et8 = ( TextView ) this.findViewById ( R.id.result8 );
			
			 c9 = ( CheckBox ) this.findViewById ( R.id.check9 );			
			 et9 = ( TextView ) this.findViewById ( R.id.result9 );
			 
			 c10 = ( CheckBox ) this.findViewById ( R.id.check10 );			
			 et10 = ( TextView ) this.findViewById ( R.id.result10 );
			 
			 c11 = ( CheckBox ) this.findViewById ( R.id.check11 );			
			 et11 = ( TextView ) this.findViewById ( R.id.result11 );
			 
			 c12 = ( CheckBox ) this.findViewById ( R.id.check12 );			
			 et12 = ( TextView ) this.findViewById ( R.id.result12 );
			 
			 c13 = ( CheckBox ) this.findViewById ( R.id.check13 );			
			 et13 = ( TextView ) this.findViewById ( R.id.result13 );
			 
			 c14 = ( CheckBox ) this.findViewById ( R.id.check14 );			
			 et14 = ( TextView ) this.findViewById ( R.id.result14 );
			 
			 c15 = ( CheckBox ) this.findViewById ( R.id.check15 );			
			 et15 = ( TextView ) this.findViewById ( R.id.result15 );
					 
			 TextSum = (TextView) findViewById(R.id.Sum);
			 Sum = (Button) findViewById(R.id.ButtonSum);
			 edit = (Button) findViewById(R.id.btnEH);
			 
			 
			 disc = (EditText) findViewById(R.id.discount);
			 disBTH = (EditText) findViewById(R.id.disBTH);
			 SumAmount = ( TextView ) this.findViewById ( R.id.SumAmount );
			 
			 sumDisc = "0";
		 	 sumDisBTH = "0";
		 	 
		 	 prom = (EditText) findViewById(R.id.VIPcode);	
			 
			 
			 btn1 = (Button) findViewById(R.id.button1);
			
			 
			    dDialog0 = new AlertDialog.Builder(this);
		 		dDialog1 = new AlertDialog.Builder(this);
		 		dDialog2 = new AlertDialog.Builder(this);
		 		dDialog3 = new AlertDialog.Builder(this);
		 		dDialog4 = new AlertDialog.Builder(this);
		
			 
		 	  id = getIntent().getExtras().getString("IntentID");	
			  getCarIDEDT = getIntent().getExtras().getString("getCarID");		
			  ServiceIDEDT = getIntent().getExtras().getString("ServiceID");	
			  RegisterIDEDT = getIntent().getExtras().getString("RegisterID");
			  TypeIDEDT = getIntent().getExtras().getString("TypeID");
			  CarGroupIDEDT = getIntent().getExtras().getString("CarGroupID");
			  
			 
			  
			 
			   System.out.println(getCarIDEDT);
			   System.out.println(ServiceIDEDT);
			   System.out.println(RegisterIDEDT);
			   System.out.println(TypeIDEDT);
			   System.out.println(CarGroupIDEDT);
			   
			   String sql = "SELECT id AS DataServiceID "+
					      ",ServiceID "+
					      ",TypeID "+
					      ",List "+
					      ",price "+
					      ",VIPcode "+
					      ",Discount "+
					      ",amount "+
					      ",Sum "+
					      ",sumTime "+
					      ",date "+
					      ",DiscountName "+
					      ",PriceBTH "+
					      ",checkOrther "+
					  "FROM DataService "+
					  "WHERE ServiceID = "+ServiceIDEDT+" ";
			   
		String listEDT = "";
		String DiscountEDT = "";
		String SumEDT = "";
		DiscountNameEDT = "";
		String amountEDT = "";
		String VIPcodeEDT = "";
		String PriceBTHEDT = "";
		String check = "";
		String PriceEDT = "";
		
				rs = con.selectData(sql);		   
				try {
					
					    rs.next();
					    listEDT = rs.getString("List"); 
					    DiscountEDT	= rs.getString("Discount"); 
					    SumEDT = rs.getString("Sum"); 
					    idDataService = rs.getString("DataServiceID"); 
					    check = rs.getString("checkOrther"); 
					    PriceEDT = rs.getString("price");
					    DiscountNameEDT = rs.getString("DiscountName");
						amountEDT = rs.getString("amount"); 
						VIPcodeEDT = rs.getString("VIPcode"); 
						PriceBTHEDT = rs.getString("PriceBTH"); 
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					//Toast.makeText(CheckCarByHedActivity.this, id , Toast.LENGTH_LONG).show();
				} 
				
				arr = listEDT.split(",");
				arr2 = PriceEDT.split(",");
				arr3 = listEDT.split(",");
				
		
				orther1();
				SumAmount.setText(amountEDT);
				TextSum.setText(SumEDT);
				
				
				if(addSer.equals("addSer")){
									
					
					prom.setEnabled(false);
					disc.setEnabled(false);
					disBTH.setEnabled(false);
					edit.setEnabled(false);			
									
									
								}else{	
									
									
								selectDis();
								prom.setText(VIPcodeEDT);
								disc.setText(DiscountEDT);
								disBTH.setText(PriceBTHEDT);
								
								
								edit.setOnClickListener(new View.OnClickListener() {
									@Override
									public void onClick(View v) {	
										
										CHECH_ADD = false;
										
								      String sql = "SELECT getCar.id AS getCarID "+
									      ",getCar.ServiceID AS ServiceID "+
									      ",getCar.RegisterID AS RegisterID "+
									      ",DataService.TypeID AS TypeID "+
									      ",CustomerCar.CarGroup AS CarGroup "+
									  
									  "FROM getCar "+ 
									  
									  "LEFT JOIN DataService "+
									  "ON getCar.ServiceID = DataService.ServiceID "+
									  
									  "LEFT JOIN CustomerCar "+
									  "ON getCar.ServiceID = CustomerCar.ServiceID "+
									  
									  "WHERE getCar.ServiceID = "+id+" ";
								      
						String 	getCarID = "";	  
						String 	ServiceID = "";
						String 	RegisterID = "";
						String 	getCarIDtoEdit = "";
						String  CarGroupID = "";
								  	rs = con.selectData(sql);		   
									try {
										//while(rs.next()){ 
										    rs.next();
										    getCarID = rs.getString("getCarID"); 
											ServiceID = rs.getString("ServiceID"); 
											RegisterID = rs.getString("RegisterID"); 
											getCarIDtoEdit = rs.getString("TypeID"); 
											CarGroupID = rs.getString("CarGroup"); 
											
										if(getCarIDtoEdit.equals("1")){	
											Intent goCheck = new Intent(services_edit.this,HoleActivity_edit.class);
										    goCheck.putExtra("getCarID", getCarID);
											goCheck.putExtra("ServiceID", ServiceID);
											goCheck.putExtra("RegisterID", RegisterID);
											goCheck.putExtra("TypeID", getCarIDtoEdit);
											goCheck.putExtra("CarGroupID", CarGroupID);
											goCheck.putExtra("IntentID", id);
											goCheck.putExtra("name", NameInput);
											goCheck.putExtra("CompanyS", company);
											goCheck.putExtra("addHole", "addHole");
											startActivityForResult(goCheck, REQUEST_CODE);	
											
										}	
										
										else{
											Intent goCheck = new Intent(services_edit.this,HoleActivity_edit.class);
										    goCheck.putExtra("getCarID", getCarID);
											goCheck.putExtra("ServiceID", ServiceID);
											goCheck.putExtra("RegisterID", RegisterID);
											goCheck.putExtra("TypeID", getCarIDtoEdit);
											goCheck.putExtra("CarGroupID", CarGroupID);
											goCheck.putExtra("IntentID", id);
											goCheck.putExtra("name", NameInput);
											goCheck.putExtra("CompanyS", company);
											goCheck.putExtra("addSer", "addSer");
											startActivityForResult(goCheck, REQUEST_CODE);	
												
										}
											
										//}
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
										Toast.makeText(services_edit.this,"Ho!!!"+id, Toast.LENGTH_LONG).show();
									}    
									 
										
									
						
								
					}
				});	
								
								
				    			
								
								}
								
								
				
				

				
				
				
				
				
    			
				for(int i=0; i<arr.length; i++){
					
					
					 if(arr[i].equals("Premium ��ҧ�Ѵ�մ/�������ͧ �����ҧ")){
						 if(arr[i+1].equals("�����")){
						 
						
						 
						String str = "",str1 = "";
						c0.setChecked(true);
						rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110004' ");
						try {
								rs2.next();
							list0 = rs2.getString("ItemName")+",";
							t0 = Integer.parseInt(rs2.getString("Duration").toString());
						} catch (SQLException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
						rs10 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
						rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110004' ");		   
						try {

							    rs.next();
							    rs10.next();
							    str = rs.getString("ItemPrice");
							    str1 = rs10.getString("ItemPrice");
							   // price0 = rs.getString("ItemPrice")+",";

						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et0.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
						a0 = Double.parseDouble(str)+Double.parseDouble(str1);
						price0 = str+","+str1+",";
					
						 } else if(arr[i].equals("Premium ��ҧ�Ѵ�մ/�������ͧ �����ҧ")){
								String str = "";
								c0.setChecked(true);
								rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110004' ");
								try {
										rs2.next();
									list0 = rs2.getString("ItemName")+",";
									t0 = Integer.parseInt(rs2.getString("Duration").toString());
								} catch (SQLException e1) {
									// TODO Auto-generated catch block
									e1.printStackTrace();
								}
								
								rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110004' ");		   
								 try {
									
									    rs.next();
									  //  rs10.next();
									    str = rs.getString("ItemPrice");
								 

								} catch (SQLException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}      
								
								
								et0.setText(df.format(Double.parseDouble(str)));
								a0 = Double.parseDouble(str);
								price0 = String.valueOf(a0)+",";  
							 
							}

					}
					 ////////////////////////////////////////////////////////////////////
					
					
					 ////////////////////////////////////////////////////////////////////
					 else if(arr[i].equals("Premium ��ҧ�Ѵ�մ/�������ͧ ��ҧ�������")){
						 if(arr[i+1].equals("�����")){
						 
						 String str = "",str1 = "";
							c0.setChecked(true);
							rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110002' ");
							try {
									rs2.next();
								list0 = rs2.getString("ItemName")+",";
								t0 = Integer.parseInt(rs2.getString("Duration").toString());
							} catch (SQLException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
							}
							rs10 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
							rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110002' ");		   
							try {

								    rs.next();
								    rs10.next();
								    str = rs.getString("ItemPrice");
								    str1 = rs10.getString("ItemPrice");
								   // price0 = rs.getString("ItemPrice")+",";

							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et0.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
							a0 = Double.parseDouble(str)+Double.parseDouble(str1);
							price0 = str+","+str1+",";
							
						 }else if(arr[i].equals("Premium ��ҧ�Ѵ�մ/�������ͧ ��ҧ�������")){
							 String str = "";
								c0.setChecked(true);
								rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110002' ");
								try {
										rs2.next();
									list0 = rs2.getString("ItemName")+",";
									t0 = Integer.parseInt(rs2.getString("Duration").toString());
								} catch (SQLException e1) {
									// TODO Auto-generated catch block
									e1.printStackTrace();
								}
								
								rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110002' ");		   
								try {

									    rs.next();
									    str = rs.getString("ItemPrice");

								} catch (SQLException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}      
								et0.setText(df.format(Double.parseDouble(str)));
								a0 = Double.parseDouble(str);
								price0 = String.valueOf(a0)+",";
								
							}
						 
						 
						 
						}
					 //////////////////////////////////////////////////////////////////////////
					 
					 
					 
					 ////////////////////////////////////////////////////////////////////////////
					 else if(arr[i].equals("Premium ��ҧ�Ѵ�մ/�������ͧ ��ҧ��������")){
						 if(arr[i+1].equals("�����")){

						 String str = "",str1 = "";
							c0.setChecked(true);
							rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110003' ");
							try {
									rs2.next();
								list0 = rs2.getString("ItemName")+",";
								t0 = Integer.parseInt(rs2.getString("Duration").toString());
							} catch (SQLException e1) {
								// TODO Auto-generated catch block 
								e1.printStackTrace();
							}
							rs10 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
							rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110003' ");		   
							try {

								    rs.next();
								    rs10.next();
								    str = rs.getString("ItemPrice");
								    str1 = rs10.getString("ItemPrice");
								   // price0 = rs.getString("ItemPrice")+",";

							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et0.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
							a0 = Double.parseDouble(str)+Double.parseDouble(str1);
							price0 = str+","+str1+",";
							
					     } else if(arr[i].equals("Premium ��ҧ�Ѵ�մ/�������ͧ ��ҧ��������")){
							 String str = "";
								c0.setChecked(true);
								rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110003' ");
								try {
										rs2.next();
									list0 = rs2.getString("ItemName")+",";
									t0 = Integer.parseInt(rs2.getString("Duration").toString());
								} catch (SQLException e1) {
									// TODO Auto-generated catch block
									e1.printStackTrace();
								}
								
								rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110003' ");		   
								try {

									    rs.next();
									  
									    str = rs.getString("ItemPrice");
									   
									   // price0 = rs.getString("ItemPrice")+",";

								} catch (SQLException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}      
								et0.setText(df.format(Double.parseDouble(str)));
								a0 = Double.parseDouble(str);
								price0 = String.valueOf(a0)+",";
								
							}
						 
						 
						}
					 ////////////////////////////////////////////////////////////////////////////


					 
					 else if(arr[i].equals("��ҧ��ǹ")){
						 if(arr[i+1].equals("�����")){
						 
							String str = "",str1 = "";
						  c1.setChecked(true);
						  
						  rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310280001' ");
							try {
								rs2.next();
								list1 = rs2.getString("ItemName")+",";
								t1 = Integer.parseInt(rs2.getString("Duration").toString());
							
							} catch (SQLException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
							}
						 
							
							
							rs10 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
							rs3 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310280001' ");		   
							try {
								//while(rs.next()){ 
								    rs3.next();
								    rs10.next();
									str = rs3.getString("ItemPrice");
									str1 = rs10.getString("ItemPrice");
									
								//}
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							} 
							 
							et1.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
							a = Double.parseDouble(str)+Double.parseDouble(str1);
							price1 = str+","+str1+",";
							
						 }	 else if(arr[i].equals("��ҧ��ǹ")){
								String str = "";
			  				  c1.setChecked(true);
			  				  
			  				  rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310280001' ");
				    				try {
				    					rs2.next();
				    					list1 = rs2.getString("ItemName")+",";
				    					t1 = Integer.parseInt(rs2.getString("Duration").toString());
				    				
				    				} catch (SQLException e1) {
				    					// TODO Auto-generated catch block
				    					e1.printStackTrace();
				    				}
				    			 
									rs3 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310280001' ");		   
									try {
										    rs3.next();
											str = rs3.getString("ItemPrice");
										
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									} 
									 
									et1.setText(df.format(Double.parseDouble(str)));
									a = Double.parseDouble(str);
									price1 = String.valueOf(a)+",";
			  				}
						 
						 
						}
					 
					 
					 /////////////////////////////////////////////// ��ҧ�Ѵ�մ�� ////////////////////
				
					 ///////////////////////////////////////////////////////////////////
					 
				
					 
					 
					 
					 
					 /////////////////////////////////   "��ҧ�� �ٴ�����������"
			    				
			    				else if(arr[i].equals("��ҧ�� �ٴ���")){
			    					 if(arr[i+1].equals("�����")){
			    					
			    					String str = "",str1 = "";
			    					c2.setChecked(true);
			    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100001' ");
				    				try {
				    					rs2.next();
				    					list2 = rs2.getString("ItemName")+",";
				    					t2 = Integer.parseInt(rs2.getString("Duration").toString());
				    					
				    				} catch (SQLException e1) {
				    					// TODO Auto-generated catch block
				    					e1.printStackTrace();
				    				}
				    				rs10 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
				    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100001' ");		   
									try {

										    rs.next();
										    rs10.next();
										    str = rs.getString("ItemPrice");
										    str1 = rs10.getString("ItemPrice");
										   // price2 = rs.getString("ItemPrice")+",";
					
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}      
									et2.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
									b = Double.parseDouble(str)+Double.parseDouble(str1);
									price2 = str+","+str1+",";
									
			    					 }
			    					 
			    					 else if(arr[i].equals("��ҧ�� �ٴ���")){
			    	    					String str = "";
			    	    					c2.setChecked(true);
			    	    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100001' ");
			    		    				try {
			    		    					rs2.next();
			    		    					list2 = rs2.getString("ItemName")+",";
			    		    					t2 = Integer.parseInt(rs2.getString("Duration").toString());
			    		    					
			    		    				} catch (SQLException e1) {
			    		    					// TODO Auto-generated catch block
			    		    					e1.printStackTrace();
			    		    				}
			    		    				
			    		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100001' ");		   
			    							try {

			    								    rs.next();
			    								    
			    								    str = rs.getString("ItemPrice");
			    			
			    							} catch (SQLException e) {
			    								// TODO Auto-generated catch block
			    								e.printStackTrace();
			    							}      
			    							et2.setText(df.format(Double.parseDouble(str)));
			    							b = Double.parseDouble(str);
			    							price2 = String.valueOf(b)+",";
			    	    				}
			    				}
					 			///////////////////////////////////////////////////////////////
					 
			    				
					 
			    				
			    				//////////////////////////////////// "��ҧ�Ѵ�մ��ԡ�÷ͧ��������"
			    				
			    				else if(arr[i].equals("��ҧ�Ѵ�մ��ԡ�÷ͧ")){
			    					 if(arr[i+1].equals("�����")){
			    					
			    					String str = "",str1 = "";
			    					c4.setChecked(true);
			    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100003' ");
				    				try {
				    					rs2.next();
				    					list4 = rs2.getString("ItemName")+",";
				    					t4 = Integer.parseInt(rs2.getString("Duration").toString());
				    				} catch (SQLException e1) {
				    					// TODO Auto-generated catch block
				    					e1.printStackTrace();
				    				}
				    				rs10 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
				    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100003' ");		   
									try {

										    rs.next();
										    rs10.next();
										    str = rs.getString("ItemPrice");
										    str1 = rs10.getString("ItemPrice");
										    //price4 = rs.getString("ItemPrice")+",";
					
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}      
									et4.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
									d = Double.parseDouble(str)+Double.parseDouble(str1);
									price4 = str+","+str1+",";
									
									
			    					 }else if(arr[i].equals("��ҧ�Ѵ�մ��ԡ�÷ͧ")){
			    	    					String str = "";
			    	    					c4.setChecked(true);
			    	    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100003' ");
			    		    				try {
			    		    					rs2.next();
			    		    					list4 = rs2.getString("ItemName")+",";
			    		    					t4 = Integer.parseInt(rs2.getString("Duration").toString());
			    		    				} catch (SQLException e1) {
			    		    					// TODO Auto-generated catch block
			    		    					e1.printStackTrace();
			    		    				}
			    		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100003' ");		   
			    							try {
 
			    								    rs.next();
			    								    str = rs.getString("ItemPrice");
			    	 		
			    							} catch (SQLException e) {
			    								// TODO Auto-generated catch block
			    								e.printStackTrace();
			    							}      
			    							et4.setText(df.format(Double.parseDouble(str)));
			    							d = Double.parseDouble(str);
			    							price4 = String.valueOf(d)+",";
			    	    				}
			    				}
					 //////////////////////////////////////////////////////////////////////
		 
		 //////////////////////////////////////////////////////////////////////
    				else if(arr[i].equals("��ҧ�������ͧ���¹�������")){
    					String str = "";
    					c5.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100004' ");
	    				try {
	    					rs2.next();
	    					list5 = rs2.getString("ItemName")+",";
	    					t5 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100004' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price5 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et5.setText(df.format(Double.parseDouble(str)));
						 e = Double.parseDouble(str);
    				}
    				else if(arr[i].equals("��ҧ�������ͧ���¹������� (�����)")){
    					String str = "";
    					c6.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100005' ");
	    				try {
	    					rs2.next();
	    					list6 = rs2.getString("ItemName")+",";
	    					t6 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100005' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price6 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et6.setText(df.format(Double.parseDouble(str)));
						 f = Double.parseDouble(str);
    				}
    				else if(arr[i].equals("����ç�Ѵ : �ӹ�������ͧ")){
    					String str = "";
    					c7.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100006' ");
	    				try {
	    					rs2.next();
	    					list7 = rs2.getString("ItemName")+",";
	    					t7 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100006' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price7 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et7.setText(df.format(Double.parseDouble(str)));
						 g = Double.parseDouble(str);
    				}
    				else if(arr[i].equals("����ç���ͺ : �ӹ�������ͧ")){
    					String str = "";
    					c8.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100007' ");
	    				try {
	    					rs2.next();
	    					list8 = rs2.getString("ItemName")+",";
	    					t8 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100007' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price8 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et8.setText(df.format(Double.parseDouble(str)));
						 h = Double.parseDouble(str);
    				}
    				else if(arr[i].equals("�Ѵ-���ͺ�� �ú�ش���¹���� Wurth")){
    					String str = "";
    					c9.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100008' ");
	    				try {
	    					rs2.next();
	    					list9 = rs2.getString("ItemName")+",";
	    					t9 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100008' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price9 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
					    et9.setText(df.format(Double.parseDouble(str)));
					    ii = Double.parseDouble(str);
					    
    				}
    				else if(arr[i].equals("���ͺ��ö���� ���¹���� Wurth / Eagle 1")){
    					String str = "";
    					c10.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100009' ");
	    				try {
	    					rs2.next();
	    					list10 = rs2.getString("ItemName")+",";
	    					t10 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100009' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price10 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et10.setText(df.format(Double.parseDouble(str)));
						 jj = Double.parseDouble(str);
    				}
    				else if(arr[i].equals("�͡��� (��������)")){
    					String str = "";
    					c11.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100010' ");
	    				try {
	    					rs2.next();
	    					list11 = rs2.getString("ItemName")+",";
	    					t11 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100010' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price11 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et11.setText(df.format(Double.parseDouble(str)));
						 k = Double.parseDouble(str);
    				}
    				else if(arr[i].equals("�͡��� (˹ѧ)")){
    					String str = "";
    					c12.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100011' ");
	    				try {
	    					rs2.next();
	    					list12 = rs2.getString("ItemName")+",";
	    					t12 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100011' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price12 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et12.setText(df.format(Double.parseDouble(str)));
						 l = Double.parseDouble(str);
    				}
    				else if(arr[i].equals("�͡ྴҹ")){
    					String str = "";
    					c13.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100012' ");
	    				try {
	    					rs2.next();
	    					list13 = rs2.getString("ItemName")+",";
	    					t13 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100012' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price13 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et13.setText(df.format(Double.parseDouble(str)));
						 m = Double.parseDouble(str);
    				}
    				else if(arr[i].equals("�͡ἧ��е�")){
    					String str = "";
    					c14.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100013' ");
	    				try {
	    					rs2.next();
	    					list14 = rs2.getString("ItemName")+",";
	    					t14 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100013' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price14 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et14.setText(df.format(Double.parseDouble(str)));
						 n = Double.parseDouble(str);
    				}
    				else if(arr[i].equals("�ѡ���")){
    					String str = "";
    					c15.setChecked(true);
    					rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100014' ");
	    				try {
	    					rs2.next();
	    					list15 = rs2.getString("ItemName")+",";
	    					t15 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100014' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price15 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et15.setText(df.format(Double.parseDouble(str)));
						 o = Double.parseDouble(str);
    				}
    				
    			
               }
				
	//============================================================check Orther========================
		if(!check.equals("")){
			
			c16.setChecked(true);
			
			String a = "";
			String b = "";
			String c = "";
			
			if(arr[(arr.length-3)].equals("-")) {
				a = "";
			}else{
				a = arr[(arr.length-3)];
			}
			
			if(arr[(arr.length-2)].equals("-")) {
				b = "";
			}else{
				b = ","+arr[(arr.length-2)];
			}
			
			if(arr[(arr.length-1)].equals("-")) {
				c = "";
			}else{
				c = ","+arr[(arr.length-1)];
			}
			orther1.setText(a+b+c);
			
			
			double aa = 0;
			double bb = 0;
			double cc = 0;
		
			if(arr2[(arr2.length-3)].equals("-")) {
				aa = 0;
			}else{
				aa = Double.parseDouble(arr2[(arr.length-3)]);
			}
					
			if(arr2[(arr2.length-2)].equals("-")) {
				bb = 0;
			}else{
				bb = Double.parseDouble(arr2[(arr2.length-2)]);
			}
			
			if(arr2[(arr2.length-1)].equals("-")) {
				cc = 0;
			}else{
				cc = Double.parseDouble(arr2[(arr2.length-1)]);
			}
			double p = aa+bb+cc; 
			et16.setText(df.format(p));
			
			 Toast.makeText(services_edit.this, "p = "+p, Toast.LENGTH_SHORT).show();
			 Toast.makeText(services_edit.this, "aa = "+aa, Toast.LENGTH_SHORT).show();
			 
			 Toast.makeText(services_edit.this, "bb = "+bb, Toast.LENGTH_SHORT).show();
			 Toast.makeText(services_edit.this, "cc = "+cc, Toast.LENGTH_SHORT).show();
		}
		//============================================================check Orther========================
			

    	
	  //========= case 1 ============================================================ 	   			 

			
	c1.setOnClickListener(new View.OnClickListener() {
		String str,str1;
		@Override
		public void onClick(View v) {
			if(c1.isChecked()){
				
				dDialog2.setTitle("��س����͡ ");
				dDialog2.setIcon(android.R.drawable.btn_star_big_on); 
				dDialog2.setMessage("��ͧ�����ꡫ���������");
				dDialog2.setPositiveButton("��ͧ���",
  					new DialogInterface.OnClickListener() {
				    public void onClick(DialogInterface dialog,int id) {
					
				    	/** �ѧ�������� OID�ͧ �������� �Դ�ѭ�� Insert Item �����ѧ��ҹ�����**/
				
				    	
				    	
				rs3 = con.selectData("SELECT * FROM Item WHERE OID = '104201311090001' ");    	
				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310280001' ");
				try {
					rs2.next();
					rs3.next();
					
					list1 = rs2.getString("ItemName")+"���"+rs3.getString("ItemName")+",";		
					t1 = Integer.parseInt(rs2.getString("Duration").toString())+
							Integer.parseInt(rs3.getString("Duration").toString());
				
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			 
				rs0 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");	
				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310070001' ");		   
				try {
					 
					    rs.next();
					    rs0.next();
						str = rs.getString("ItemPrice");
						str1 = rs0.getString("ItemPrice");
						
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}    
				 
				et1.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
				a = Double.parseDouble(str)+Double.parseDouble(str1);
				price1 = String.valueOf(a)+",";
				    }
				  });
				
				/////////////////////////////// + waxz /////////////////////
            	
				dDialog2.setNegativeButton("����ͧ���",
	  					  new DialogInterface.OnClickListener() {
					    public void onClick(DialogInterface dialog,int id) {
					    	
					    	rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310280001' ");
		    				try {
		    					rs2.next();
		    					list1 = rs2.getString("ItemName")+",";
		    					t1 = Integer.parseInt(rs2.getString("Duration").toString());
		    				
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    			 
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310070001' ");		   
							try {
								
								    rs.next();
									str = rs.getString("ItemPrice");
									price1 = rs.getString("ItemPrice")+",";
									
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}    
							 
							et1.setText(df.format(Double.parseDouble(str)));
							a = Double.parseDouble(str);
							
							    }
							  });
				dDialog2.show();
				}
			else {
				
				t1 = 0;
				 a = 0;
				 list1 = "";
				 price1="";
				et1.setText("");
				}
        }
    });
			   //========= case 2 ============================================================ 			  
	
	c2.setOnClickListener(new View.OnClickListener() {
		String str,str1;
		@Override
		public void onClick(View v) {
			if(c2.isChecked()){
				
				
					
				
		            	
		            	dDialog1.setTitle("��س����͡ ");
		            	dDialog1.setIcon(android.R.drawable.btn_star_big_on); 
		            	dDialog1.setMessage("��ͧ�����ꡫ���������");
		            	dDialog1.setPositiveButton("��ͧ���",
		  					  new DialogInterface.OnClickListener() {
						    public void onClick(DialogInterface dialog,int id) {
							
						    	/** �ѧ�������� OID�ͧ �������� �Դ�ѭ�� Insert Item �����ѧ��ҹ�����**/
						    	rs3 = con.selectData("SELECT * FROM Item WHERE OID = '104201311090001' ");    	
						    	rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100001' ");
			    				try {
			    					rs2.next();
			    					rs3.next();
			    					list2 = rs2.getString("ItemName")+"���"+rs3.getString("ItemName")+",";		
			    					t2 = Integer.parseInt(rs2.getString("Duration").toString())+
			    							Integer.parseInt(rs3.getString("Duration").toString());
			    					
			    				} catch (SQLException e1) {
			    					// TODO Auto-generated catch block
			    					e1.printStackTrace();
			    				}
			    				rs0 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
			    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100001' ");		   
								try {

									    rs.next();
									    rs0.next();
									    str = rs.getString("ItemPrice");
									    str1 = rs.getString("ItemPrice");
									    
				
								} catch (SQLException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}      
								et2.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
								b = Double.parseDouble(str)+Double.parseDouble(str1);
								price2 =String.valueOf(b)+",";
						    }
						  });

		            	
		          
		            	
		            	
		            	dDialog1.setNegativeButton("����ͧ���",
		  					  new DialogInterface.OnClickListener() {
						    public void onClick(DialogInterface dialog,int id) {


						    	
			    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100001' ");
			    				try {
			    					rs2.next();
			    					list2 = rs2.getString("ItemName")+",";
			    					t2 = Integer.parseInt(rs2.getString("Duration").toString());
			    					
			    				} catch (SQLException e1) {
			    					// TODO Auto-generated catch block
			    					e1.printStackTrace();
			    				}
			    				
			    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100001' ");		   
								try {

									    rs.next();
									    str = rs.getString("ItemPrice");
									    price2 = rs.getString("ItemPrice")+",";
				
								} catch (SQLException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}      
								et2.setText(df.format(Double.parseDouble(str)));
								b = Double.parseDouble(str);
						    }
						  });
		            	dDialog1.show();
			

				}
			else {
				 b = 0;
				 t2 = 0;
				 list2 = "";
				 price2="";
				et2.setText("");
				}
        }
    }); 
			//////////////////////////////////////////
	    				
	    				
	c0.setOnClickListener(new View.OnClickListener() {
		String str,str1;
		@Override
		public void onClick(View v) {
			if(c0.isChecked()){
				
				dDialog0.setTitle("��س����͡ ");
				dDialog0.setIcon(android.R.drawable.btn_star_big_on); 
				dDialog0.setMessage("��ͧ�����ҧ�������ͧ�����������");
				dDialog0.setPositiveButton("��ҧ�������",
  					new DialogInterface.OnClickListener() {
					
				    public void onClick(DialogInterface dialog,int id) {
					
				    	
				
				
				///////////////////////////////////////////////////
				
				dDialog3.setTitle("��س����͡ ");
				dDialog3.setIcon(android.R.drawable.btn_star_big_on); 
				dDialog3.setMessage("��ͧ�����ꡫ���������");
				dDialog3.setPositiveButton("��ͧ���",
  					  new DialogInterface.OnClickListener() {
				    public void onClick(DialogInterface dialog,int id) {
					
				    	
				rs3 = con.selectData("SELECT * FROM Item WHERE OID = '104201311090001' ");    	    	
				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110002' ");
				try {
 					rs2.next();
 					rs3.next();
					list0 = rs2.getString("ItemName")+"���"+rs3.getString("ItemName")+",";		
					t0 = Integer.parseInt(rs2.getString("Duration").toString())+
							Integer.parseInt(rs3.getString("Duration").toString());
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				
				rs0 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110002' ");		   
				try {

					    rs.next();
					    rs0.next();
					    str = rs.getString("ItemPrice");
					    str1 = rs0.getString("ItemPrice");
					    //price0 = rs.getString("ItemPrice")+rs0.getString("ItemPrice")+",";

				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}      
				et0.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
				a0 = Double.parseDouble(str)+Double.parseDouble(str1);
				price0 = String.valueOf(a0)+",";
				
				    }
				    });
            	

				dDialog3.setNegativeButton("����ͧ���",
  					  new DialogInterface.OnClickListener() {
				    public void onClick(DialogInterface dialog,int id) {
				    	
				    	rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110002' ");
	    				try {
	     					rs2.next();
	    					list0 = rs2.getString("ItemName")+",";
	    					t0 = Integer.parseInt(rs2.getString("Duration").toString());
	    				} catch (SQLException e1) {
	    					// TODO Auto-generated catch block
	    					e1.printStackTrace();
	    				}
	    				
	    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110002' ");		   
						try {

							    rs.next();
							    str = rs.getString("ItemPrice");
							    price0 = rs.getString("ItemPrice")+",";
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      
						et0.setText(df.format(Double.parseDouble(str)));
						a0 = Double.parseDouble(str);
						    }
						    });
				dDialog3.show();
				
				
				//////////////////////////////////////////////////
				
				
				    }
				  });
				
				
				
////////////////////////////////////////////////////////////////////////////////////////////
				dDialog0.setNeutralButton("��ҧ��������",
	  					  new DialogInterface.OnClickListener() {
					    public void onClick(DialogInterface dialog,int id) {
					    	
							///////////////////////////////////////////////////
							
							dDialog3.setTitle("��س����͡ ");
		    				dDialog3.setIcon(android.R.drawable.btn_star_big_on); 
		    				dDialog3.setMessage("��ͧ�����ꡫ���������");
		    				dDialog3.setPositiveButton("��ͧ���",
			  					  new DialogInterface.OnClickListener() {
							    public void onClick(DialogInterface dialog,int id) {
								
							    	
							rs3 = con.selectData("SELECT * FROM Item WHERE OID = '104201311090001' ");    	    	
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110003' ");
		    				try {
		     					rs2.next();
		     					rs3.next();
		    					list0 = rs2.getString("ItemName")+"���"+rs3.getString("ItemName")+",";		
		    					t0 = Integer.parseInt(rs2.getString("Duration").toString())+
		    							Integer.parseInt(rs3.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs0 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110003' ");		   
							try {

								    rs.next();
								    rs0.next();
								    str = rs.getString("ItemPrice");
								    str1 = rs0.getString("ItemPrice");
								   // price0 = rs.getString("ItemPrice")+rs0.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et0.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
							a0 = Double.parseDouble(str)+Double.parseDouble(str1);
							price0 = String.valueOf(a0)+",";
							
							    }
							    });
			            	

		    				dDialog3.setNegativeButton("����ͧ���",
			  					  new DialogInterface.OnClickListener() {
							    public void onClick(DialogInterface dialog,int id) {
							    	
							    	rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110003' ");
				    				try {
				     					rs2.next();
				    					list0 = rs2.getString("ItemName")+",";
				    					t0 = Integer.parseInt(rs2.getString("Duration").toString());
				    				} catch (SQLException e1) {
				    					// TODO Auto-generated catch block
				    					e1.printStackTrace();
				    				}
				    				
				    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110003' ");		   
									try {

										    rs.next();
										    str = rs.getString("ItemPrice");
										    price0 = rs.getString("ItemPrice")+",";
					
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}      
									et0.setText(df.format(Double.parseDouble(str)));
									a0 = Double.parseDouble(str);
									    }
									    });
		    				dDialog3.show();
							
		    				
							//////////////////////////////////////////////////
							
							    }
							  });
				dDialog0.setNegativeButton("�����ҧ",
	  					  new DialogInterface.OnClickListener() {
					    public void onClick(DialogInterface dialog,int id) {
					    	
							///////////////////////////////////////////////////
							
							dDialog3.setTitle("��س����͡ ");
		    				dDialog3.setIcon(android.R.drawable.btn_star_big_on); 
		    				dDialog3.setMessage("��ͧ�����ꡫ���������");
		    				dDialog3.setPositiveButton("��ͧ���",
			  					  new DialogInterface.OnClickListener() {
							    public void onClick(DialogInterface dialog,int id) {
								
							    	
							rs3 = con.selectData("SELECT * FROM Item WHERE OID = '104201311090001' ");    	    	
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110004' ");
		    				try {
		     					rs2.next();
		     					rs3.next();
		    					list0 = rs2.getString("ItemName")+"���"+rs3.getString("ItemName")+",";		
		    					t0 = Integer.parseInt(rs2.getString("Duration").toString())+
		    							Integer.parseInt(rs3.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs0 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110004' ");		   
							try {

								    rs.next();
								    rs0.next();
								    str = rs.getString("ItemPrice");
								    str1 = rs0.getString("ItemPrice");
								    //price0 = rs.getString("ItemPrice")+rs0.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et0.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
							a0 = Double.parseDouble(str)+Double.parseDouble(str1);
							price0 = String.valueOf(a0)+",";
							
							    }
							    });
			            	

		    				dDialog3.setNegativeButton("����ͧ���",
			  					  new DialogInterface.OnClickListener() {
							    public void onClick(DialogInterface dialog,int id) {
							    	
							    	rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201311110004' ");
				    				try {
				     					rs2.next();
				    					list0 = rs2.getString("ItemName")+",";
				    					t0 = Integer.parseInt(rs2.getString("Duration").toString());
				    				} catch (SQLException e1) {
				    					// TODO Auto-generated catch block
				    					e1.printStackTrace();
				    				}
				    				
				    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311110004' ");		   
									try {

										    rs.next();
										    str = rs.getString("ItemPrice");
										    price0 = rs.getString("ItemPrice")+",";
					
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}      
									et0.setText(df.format(Double.parseDouble(str)));
									a0 = Double.parseDouble(str);
									    }
									    });
		    				dDialog3.show();
							
		    				
							//////////////////////////////////////////////////
							
							
							    }
							  });
				dDialog0.show();
				}
			else {
				
				t0 = 0;
				 a0 = 0;
				 list0 = "";
				 price0 ="";
				et0.setText("");
				}
        }
	});
/////////////////////////////////////////////////////////
	    				
	    				
	
	c4.setOnClickListener(new View.OnClickListener() {
		String str,str1;
		@Override
		public void onClick(View v) {
			if(c4.isChecked()){
				
				dDialog4.setTitle("��س����͡ ");
				dDialog4.setIcon(android.R.drawable.btn_star_big_on); 
				dDialog4.setMessage("��ͧ�����ꡫ���������");
				dDialog4.setPositiveButton("��ͧ���",
  					  new DialogInterface.OnClickListener() {
				    public void onClick(DialogInterface dialog,int id) {
					
				    	/** �ѧ�������� OID�ͧ �������� �Դ�ѭ�� Insert Item �����ѧ��ҹ�����**/
				rs3 = con.selectData("SELECT * FROM Item WHERE OID = '104201311090001' ");    	    	
				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100003' ");
				try {
					rs2.next();
					rs3.next();
					list4 = rs2.getString("ItemName")+"���"+rs3.getString("ItemName")+",";		
					t4 =  Integer.parseInt(rs2.getString("Duration").toString())+
							Integer.parseInt(rs3.getString("Duration").toString());
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				
				rs0 = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201311090001' ");
				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100003' ");		   
				try {

					    rs.next();
					    rs0.next();
					    str = rs.getString("ItemPrice");
					    str1 = rs0.getString("ItemPrice");
					   
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}      
				et4.setText(df.format(Double.parseDouble(str)+Double.parseDouble(str1)));
				d = Double.parseDouble(str)+Double.parseDouble(str1);
				price4 = String.valueOf(d)+",";
				}
            	});
            	
            	
				dDialog4.setNegativeButton("����ͧ���",
	  					  new DialogInterface.OnClickListener() {
					    public void onClick(DialogInterface dialog,int id) {
            	rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100003' ");
				try {
					rs2.next();
					list4 = rs2.getString("ItemName")+",";
					t4 = Integer.parseInt(rs2.getString("Duration").toString());
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
				
				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100003' ");		   
				try {

					    rs.next();
					    str = rs.getString("ItemPrice");
					    price4 = rs.getString("ItemPrice")+",";

				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}      
				et4.setText(df.format(Double.parseDouble(str)));
				d = Double.parseDouble(str);
				}
            	});
            	
				dDialog4.show();
            	
			}
			else {
				t4 = 0;
				list4 = "";
				price4="";
				 d = 0;
				et4.setText("");
				}
        }
    });
			
	    				
				c5.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c5.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100004' ");
		    				try {
		    					rs2.next();
		    					list5 = rs2.getString("ItemName")+",";
		    					t5 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100004' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price5 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et5.setText(df.format(Double.parseDouble(str)));
							 e = Double.parseDouble(str);
		    				}
		    			else {
		    				t5 = 0;
		    				list5 = "";
		    				price5="";
		    				 e = 0;
		    				et5.setText("");
		    				}
		            }
		        });
	    				
				c6.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c6.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100005' ");
		    				try {
		    					rs2.next();
		    					list6 = rs2.getString("ItemName")+",";
		    					t6 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100005' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price6 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et6.setText(df.format(Double.parseDouble(str)));
							 f = Double.parseDouble(str);
		    				}
		    			else {
		    				t6 = 0;
		    				list6 = "";
		    				price6="";
		    				 f = 0;
		    				et6.setText("");
		    				}
		            }
		        });
	    				
				c7.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c7.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100006' ");
		    				try {
		    					rs2.next();
		    					list7 = rs2.getString("ItemName")+",";
		    					t7 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100006' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price7 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et7.setText(df.format(Double.parseDouble(str)));
							 g = Double.parseDouble(str);
		    				}
		    			else {
		    				t7 = 0;
		    				list7 = "";
		    				price7="";
		    				 g = 0;
		    				et7.setText("");
		    				}
		            }
		        });
	    				
	    				
				c8.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c8.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100007' ");
		    				try {
		    					rs2.next();
		    					list8 = rs2.getString("ItemName")+",";
		    					t8 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100007' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price8 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et8.setText(df.format(Double.parseDouble(str)));
							 h = Double.parseDouble(str);
		    				}
		    			else {
		    				t8 = 0;
		    				list8 = "";
		    				price8="";
		    				 h = 0;
		    				et8.setText("");
		    				}
		            }
		        });
	    				
				c9.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c9.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100008' ");
		    				try {
		    					rs2.next();
		    					list9 = rs2.getString("ItemName")+",";
		    					t9 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100008' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price9 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
						    et9.setText(df.format(Double.parseDouble(str)));
						    ii = Double.parseDouble(str);
							
		    				}
		    			else {
		    				t9 = 0;
		    				list9 = "";
		    				price9="";
		    				 ii = 0;
		    				et9.setText("");
		    				}
		            }
		        });
				
				
				c10.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c10.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100009' ");
		    				try {
		    					rs2.next();
		    					list10 = rs2.getString("ItemName")+",";
		    					t10 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100009' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price10 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et10.setText(df.format(Double.parseDouble(str)));
							 jj = Double.parseDouble(str);
		    				}
		    			else {
		    				t10 = 0;
		    				list10 = "";
							price10="";
		    				 jj = 0;
		    				et10.setText("");
		    				}
		            }
		        });
				
				
				c11.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c11.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100010' ");
		    				try {
		    					rs2.next();
		    					list11 = rs2.getString("ItemName")+",";
		    					t11 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100010' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price11 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et11.setText(df.format(Double.parseDouble(str)));
							 k = Double.parseDouble(str);
		    				}
		    			else {
		    				t11 = 0;
		    				list11 = "";
		    				price11="";
		    				 k = 0;
		    				et11.setText("");
		    				}
		            } 
		        });
				
				
				c12.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c12.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100011' ");
		    				try {
		    					rs2.next();
		    					list12 = rs2.getString("ItemName")+",";
		    					t12 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100011' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price12 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et12.setText(df.format(Double.parseDouble(str)));
							 l = Double.parseDouble(str);
		    				}
		    			else {
		    				t12 = 0;
		    				list12 = "";
		    				price12="";
		    				 l = 0;
		    				et12.setText("");
		    				}
		            }
		        });
				
				
				c13.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c13.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100012' ");
		    				try {
		    					rs2.next();
		    					list13 = rs2.getString("ItemName")+",";
		    					t13 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100012' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price13 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et13.setText(df.format(Double.parseDouble(str)));
							 m = Double.parseDouble(str);
		    				}
		    			else {
		    				t13 = 0;
		    				list13 = "";
		    				price13="";
		    				 m = 0;
		    				et13.setText("");
		    				}
		            }
		        });
				
				c14.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c14.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100013' ");
		    				try {
		    					rs2.next();
		    					list14 = rs2.getString("ItemName")+",";
		    					t14 = Integer.parseInt(rs2.getString("Duration").toString());
		    				} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100013' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price14 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et14.setText(df.format(Double.parseDouble(str)));
							 n = Double.parseDouble(str);
		    				}
		    			else {
		    				t14 = 0;
		    				list14 = "";
		    				price14="";
		    				 n = 0;
		    				et14.setText("");
		    				}
		            }
		        });
				
				
				c15.setOnClickListener(new View.OnClickListener() {
					String str;
					@Override
					public void onClick(View v) {
		    			if(c15.isChecked()){
		    				
		    				rs2 = con.selectData("SELECT * FROM Item WHERE OID = '104201310100014' ");
		    				try {
		    					rs2.next();
		    					list15 = rs2.getString("ItemName")+",";
		    					t15 = Integer.parseInt(rs2.getString("Duration").toString());
		    			   	} catch (SQLException e1) {
		    					// TODO Auto-generated catch block
		    					e1.printStackTrace();
		    				}
		    				
		    				rs = con.selectData("SELECT * FROM ItemPrice where CarGroupOID = '"+CarGroupIDEDT+"' and ItemOID = '104201310100014' ");		   
							try {

								    rs.next();
								    str = rs.getString("ItemPrice");
								    price15 = rs.getString("ItemPrice")+",";
			
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}      
							et15.setText(df.format(Double.parseDouble(str)));
							 o = Double.parseDouble(str);
							Toast.makeText(services_edit.this, "o = "+o , Toast.LENGTH_LONG).show();
		    				}
		    			else {
		    				t15 = 0;
		    				list15 = "";
		    				price15="";
		    				 o = 0;
		    				et15.setText("");
		    				}
		            }
		        });
	     				
				
	    				
			
	    			
	    				 
						Sum.setOnClickListener(new View.OnClickListener() {
							public void onClick(View v) {
								if(et16.getText().toString().equals("")){
									p = 0;
								}else{
								p = Double.parseDouble(et16.getText().toString());
								}
								
								
								//////////////  ��ǹŴ�ٻͧ	
								sumDiscNull = disc.getText().toString();
			    				
			    				if(sumDiscNull.equals(null)||sumDiscNull.equals("")){
			    					sumDisc = "0";
			    				}else{
			    					sumDisc = sumDiscNull;
			    				}
			    				sumDisBTHNull = disBTH.getText().toString();
			    				
			    				if(sumDisBTHNull.equals(null)||sumDisBTHNull.equals("")){
			    					sumDisBTH = "0";
			    				}else{
			    					
			    					sumDisBTH = sumDisBTHNull;
			    				}
			    				
			    			////////////////���ǹŴ VIP
			    				VIPcode = prom.getText().toString();
								
								timeSum = t1+t2+t0+t4+t5+t6+t7+t8+t9+t10+t11+t12+t13+t14+t15;
								timeSum = timeSum+0;
								Toast.makeText(services_edit.this, "All time is : "+timeSum, Toast.LENGTH_SHORT).show();
								
								
								amount = a0+a+b+d+e+f+g+h+ii+jj+k+l+m+n+o+p+q+r;
								
								 
								
								SumAmount.setText(String.valueOf(df.format(amount)));
								
								finalSum = (amount-Integer.parseInt(sumDisBTH))-(((amount-Integer.parseInt(sumDisBTH))*Integer.parseInt(sumDisc))/100);
								
		
			    				TextSum.setText(String.valueOf(df.format(finalSum)));	
								
							
			    				
			    				
							}
							});
						
						/////////////////////////////////////// edit Hole /////////////////////////////
						
						
						
						///////////////////////////////////////////////////////////////////////////////
						
						 
						final Calendar c = Calendar.getInstance();
						
				        mYear = c.get(Calendar.YEAR);
				        mMonth = c.get(Calendar.MONTH);
				        mDay = c.get(Calendar.DAY_OF_MONTH); 
				        
						 btn1.setOnClickListener(new View.OnClickListener() {
								public void onClick(View v) {
									
									
									if(HoleActivity_edit.CHECH_ADD){	
									
									
									if(orther1.getText().toString().equals("")){
				       					price16 = "-,";
				    	   				list16 = "-,";
				    	   				
				    	   				price17 = "-,";
				    	   				list17 = "-,";
				    	   				
				    	   				price18 = "-,";
				    	   				list18 = "-,";
				    				}else{
				    					String [] count = orther1.getText().toString().split(",");
				    					
				    					Log.i("count = ",""+count.length);
				    					Toast.makeText(services_edit.this, ""+count.length+"    "+orther1.getText().toString(), Toast.LENGTH_SHORT).show();
				    					
				    					if(count.length == 3){
				    					price16 = et16.getText().toString()+",";
				    	   				list16 = orther1.getText().toString()+",";
				    	   				
				    	   				price17 = "-,";
				    	   				
				    	   				price18 = "-,";
				    	   				
				    					}else if (count.length == 2){
				    						price16 = et16.getText().toString()+",";
					    	   				list16 = orther1.getText().toString()+",";
					    	   				
					    	   				list17 = "-,";
					    	   				price17 = "-,";
					    	   				
					    	   				price18 = "-,";
					    	   				
					    	   				
					    	   				
				    					}else if (count.length == 1){
				    						price16 = et16.getText().toString()+",";
					    	   				list16 = orther1.getText().toString()+",";
					    	   				
					    	   				price17 = "-,";
					    	   				list17 = "-,";
					    	   				
					    	   				price18 = "-,";
					    	   				list18 = "-,";
				    					}
				    				}
				    				
				    				 
				    	 			
		
									

								    String sql = "UPDATE DataService " +
											"SET List = '"+list0+list1+list2+list4+list5+list6+list7+list8+list9+
											               list10+list11+list12+list13+list14+list15+list16+list17+list18+"', " +
								    		     "price = '"+price0+price1+price2+price4+price5+price6+price7+price8+price9+
													price10+price11+price12+price13+price14+price15+price16+price17+price18+"', " +
								    		     "VIPcode = '"+VIPcode+"', "+
								    		     "Discount = '"+sumDisc+"', " +
								    		     "amount = '"+amount+"', " +
								    		     "Sum = '"+finalSum+"', " +
								    		     "sumTime = '"+timeSum+"', " +
								    		     "date = '"+mDay+"/"+(1+mMonth)+"/"+mYear+"', " +
								    		     "DiscountName = '"+DisCt+"', " +
								    		     "PriceBTH = '"+sumDisBTH+"', " +
								    		     "checkOrther = '"+checkOrther1+"' "+
								    		    
								    		     
											     "WHERE id = '"+idDataService+"' ";
								    
								   
							        
							        
								
								    
									
								  
									
								if(con.editData(sql)){	 
								Toast.makeText(services_edit.this, "Update data successfully", Toast.LENGTH_SHORT).show();
								Toast.makeText(services_edit.this,  ServiceIDEDT , Toast.LENGTH_SHORT).show();
								//Open Form Add
								
								Intent newActivityAdd = new Intent(services_edit.this,Card_Edit.class);
								newActivityAdd.putExtra("name", NameInput);
								newActivityAdd.putExtra("CompanyS", company);
								newActivityAdd.putExtra("ServiceID", ServiceIDEDT);
								startActivity(newActivityAdd);
								
								}else{
							    Toast.makeText(services_edit.this, "Update data fail", Toast.LENGTH_SHORT).show();
							   
							    
								}
								
								
								
								}
									
									else{
									

									
									
									HoleActivity_edit.CHECH_ADD = true;
									  Toast.makeText(services_edit.this, "���������", Toast.LENGTH_SHORT).show();
									  Intent i = new Intent();
										i.putExtra("time", timeSum+"");
										i.putExtra("Money", finalSum+"");
										i.putExtra("list", list0+list1+list2+list4+list5+list6+list7+list8+list9+
												list10+list11+list12+list13+list14+list15);
										i.putExtra("price", price0+price1+price2+price4+price5+price6+price7+price8+price9+
												price10+price11+price12+price13+price14+price15);
										i.putExtra("name", NameInput);
										i.putExtra("CompanyS", company);
										setResult(HoleActivity_edit.REQUEST_CODE, i);
									    finish();
									
								}
								
								}
								});
					
						
	   			
	}
	
	private void orther1() {

		  
		 
		 c16.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
	    			if(c16.isChecked()){
	    				checkOrther1 = "checkOrther";
	    				orther1.setEnabled(true);
	    				et16.setEnabled(true);	
							
							
							
			
				
	    				}
	    			else {
	    				checkOrther1 = "";
	    				p = 0;
	    				orther1.setText("0");
	    				et16.setText("0");
	    				orther1.setEnabled(false);
	    				et16.setEnabled(false);
	    				}
	            }
	        });
}


public void selectDis(){
	
	//	String tusTmp = getIntent().getExtras().getString("Status");	
		  spnDis = (Spinner) findViewById(R.id.selectDiscount);
		
		
		
		
		  
		Dis.add(DiscountNameEDT);
		Dis.add("����");
		Dis.add("�.�.�.");
		Dis.add("��ǹŴ˹���ҹ");
		 	
		
		
	ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,Dis);
	empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
	spnDis.setAdapter(empolyeeAdapter);

	spnDis.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 

	public void onItemSelected(AdapterView<?> adapterView, 
		View view, int i, long l) { 
		// TODO Auto-generated method stub
		
		
		
		DisCt = Dis.get(i);
		
		 
		
		}
	public void onNothingSelected(AdapterView<?> arg0) {
		// TODO Auto-generated method stub
		Toast.makeText(services_edit.this,
					String.valueOf("ʶҹ��ա������¹�ŧ����"),
						Toast.LENGTH_SHORT).show();
	} 

	});
	
	}

	/////////////////////////////////////////// ------------------
/////////////////////////////////////////// ------------------
/////////////////////////////////////////// ------------------
/////////////////////////////////////////// ------------------
/////////////////////////////////////////// ------------------


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	// TODO Auto-generated method stub
	super.onActivityResult(requestCode, resultCode, data);
	Log.i("Get data", requestCode+"");

	switch (requestCode) {
	case services_edit.REQUEST_CODE:
		
		final AlertDialog.Builder dDialog = new AlertDialog.Builder(this);
		
		timeHole = data.getStringExtra("time");
		sumHole = data.getStringExtra("Money");
		listHole = data.getStringExtra("list");
		priceHole = data.getStringExtra("price");
		

		arr = listHole.split(",");
		arr2 = priceHole.split(",");
		
		
		  Toast.makeText(services_edit.this, "OMG +"+timeHole+" "+sumHole+" "+listHole+" "+priceHole, Toast.LENGTH_LONG).show();
		  
		  
		  Sum.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					
					
					
					
					if(et16.getText().toString().equals("")){
						p = 0;
					}else{
					p = Double.parseDouble(et16.getText().toString());
					}
					
				
				///////////  ��ǹ ����� ////////////
					
				//////////////  ��ǹŴ�ٻͧ	
					sumDiscNull = disc.getText().toString();
    				
    				if(sumDiscNull.equals(null)||sumDiscNull.equals("")){
    					sumDisc = "0";
    				}else{
    					sumDisc = sumDiscNull;
    				}
    				sumDisBTHNull = disBTH.getText().toString();
    				
    				if(sumDisBTHNull.equals(null)||sumDisBTHNull.equals("")){
    					sumDisBTH = "0";
    				}else{
    					
    					sumDisBTH = sumDisBTHNull;
    				}
    				
    			////////////////���ǹŴ VIP
    				VIPcode = prom.getText().toString();
    				 
    				 
    				

					
					timeSum = t0+t1+t2+t4+t5+t6+t7+t8+t9+t10+t11+t12+t13+t14+t15;
					timeSum = timeSum+0;
					Toast.makeText(services_edit.this, "All time is : "+timeSum, Toast.LENGTH_SHORT).show();
					
					
					amount = a0+a+b+d+e+f+g+h+ii+jj+k+l+m+n+o+p+q+r+Double.parseDouble(sumHole);
					 
					SumAmount.setText(String.valueOf(df.format(amount)));
					
					finalSum = (amount-Integer.parseInt(sumDisBTH))-(((amount-Integer.parseInt(sumDisBTH))*Integer.parseInt(sumDisc))/100);
					

    				TextSum.setText(String.valueOf(df.format(finalSum)));	
    		
				}
				});
		
		  
		  btn1.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					

				/**	
					rs2 = con.selectData("SELECT MAX(ServiceID) AS maxid FROM CustomerCar WHERE RegisterID = '"+RegisterIDEDT+"' ");
    				try {
    					rs2.next();
    					ServiceID = rs2.getString("maxid");
    				} catch (SQLException e1) {
    					// TODO Auto-generated catch block
    					e1.printStackTrace();
    				}
    				
    				**/
    				
    				if(et16.getText().toString().equals("")){
       					price16 = "-,";
    	   				list16 = "-,";
    				}else{
    					price16 = et16.getText().toString()+",";
    	   				list16 = orther1.getText().toString()+",";
    				}
    				
    				
    					price17 = "-,";
    	   				list17 = "-,";
    				
    					price18 = "-,";
    	   				list18 = "-,";
    				
					

					
    	   				String sql = "UPDATE DataService " +
    							"SET List='"+list0+list1+list2+list4+list5+list6+list7+list8+list9+
    							list10+list11+list12+list13+list14+listHole+list15+list16+list17+"'" +
    									",price='"+price0+price1+price2+price4+price5+price6+price7+price8+price9+
    									price10+price11+price12+price13+price14+priceHole+price15+price16+price17+"'" +
    											",VIPcode='"+VIPcode+"',Discount='"+sumDisc+"',amount='"+amount+"'" +
    													",Sum='"+finalSum+"',sumTime='"+timeSum+"',date='"+mDay+"/"+(1+mMonth)+"/"+mYear+"'" +
    										",DiscountName='"+DisCt+"',PriceBTH='"+sumDisBTH+"',checkOrther='"+checkOrther1+"' " +
    													"WHERE ServiceID ='"+ServiceIDEDT+"' ";
    				
    				
					
				if(con.addData(sql)){	 
				Toast.makeText(services_edit.this, "Inserted data successfully ADD HOLE", Toast.LENGTH_SHORT).show();
				//Open Form Add
				Toast.makeText(services_edit.this, ServiceIDEDT, Toast.LENGTH_SHORT).show();
				Intent newActivityAdd = new Intent(services_edit.this,Card_Edit.class);
				newActivityAdd.putExtra("ServiceID", ServiceIDEDT);
				newActivityAdd.putExtra("name", NameInput);
				newActivityAdd.putExtra("CompanyS", company);
				startActivity(newActivityAdd);
				
				}else{
			    Toast.makeText(services_edit.this, "Inserted data fail ADD HOLE", Toast.LENGTH_SHORT).show();
			    
			    
				}
				
				
        
				
				

				}
				});			
		break;

	default:
		break;
	}	
	
}



/////////////////////////////////////////// ------------------
/////////////////////////////////////////// ------------------
/////////////////////////////////////////// ------------------
/////////////////////////////////////////// ------------------	
/////////////////////////////////////////// ------------------
	@Override
	public void onBackPressed() {
	  
	        new AlertDialog.Builder(this)
	        .setTitle("¡��ԡ��÷���¡��")
	        .setMessage("��Ѻ�˹����ѡ")
	                .setNegativeButton(android.R.string.yes, new DialogInterface.OnClickListener() {

	                    public void onClick(DialogInterface arg0, int arg1) {
	                        Intent newActivity = new Intent(getApplicationContext(),MainActivity.class);	                          
	                        newActivity.putExtra("name", NameInput);
							newActivity.putExtra("CompanyS", company);
	                        startActivity(newActivity);
	                        finish();
	                        overridePendingTransition(R.layout.fadeendout,R.layout.fadeendin);
	                    }
	                })
	                .setPositiveButton(android.R.string.no, null).create().show();
	    

	}
	

}
